<?php
/**
 * @Author Nguyen Van Khoi (khoihhp@yahoo.com)
 * @copyright Nguyen Van Khoi
 * @createdate 30/09/2010
 */
//////////////////////////////
if ( ! defined( 'NV_SYSTEM' ) ) die( 'Stop!!!' );

global $global_config, $module_name, $module_data, $global_array_cat;
$limit = 10; //so ban tin 
$Scroll = 1;//Co cho noi dung cua block chay tu duoi len tren hay khong. 0 - khong, 1 - dong y 
$bgcolor1 = "red";//"#FFFFAA";
$bgcolor2 = "navy";//"#06FF83";
$bgcolor_2 = "#FFFFFF";//"#FFFFAA";
$bgcolor_1 = "#F2F2F2";//"#06FF83";

############### Het phan khai bao ########################## 
$array_block_news = array();
$result1 = "SELECT id, listcatid, publtime, exptime, title, alias, homeimgthumb FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`= 1 AND `publtime` < " . NV_CURRENTTIME . " AND (`exptime`=0 OR `exptime`>" . NV_CURRENTTIME . ") ORDER BY `publtime` DESC LIMIT 0 , 20";
$numstories = $db->sql_query( $result1 );

$a = 1; 
$content = ""; 
if($numstories > 0) { 
	
$content .= "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n<tr>\n<td>"; 
	//Neu cho chay ban tin
if ($Scroll) { 
$content .= "<marquee behavior= \"scroll\" align= \"center\" direction= \"up\" height=\"230\" scrollamount= \"1\" scrolldelay= \"5\" onmouseover='this.stop()' onmouseout='this.start()'>";
} 
	//Bang chua tung ban tin
$content .= "<table width=\"100%\" border=\"0\" bordercolor=\"#000080\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\">\n"; 

while ($rowlast1 = $db->sql_fetchrow($numstories)) {
$id = intval($rowlast1['id']);
$catid = end( explode( ",", $rowlast1['listcatid'] ) );
$hometext = stripslashes($rowlast1['title']);
$alias =stripslashes($rowlast1['alias']);
$imgurl = "";
//$imagesizex = $imagesizey = 0;
$homeimgthumb = $rowlast1['homeimgthumb'];
        if ( $homeimgthumb != "" )
        {
            $arr_homeimgthumb = explode( "|", $homeimgthumb );
            if ( isset( $arr_homeimgthumb[1] ) and ! empty( $arr_homeimgthumb[1] ) and file_exists( NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $arr_homeimgthumb[1] ) )
            {
                $imgurl = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_name . '/' . $arr_homeimgthumb[1];
 //               $size = @getimagesize( NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $arr_homeimgthumb[1] );
 //               $imagesizex = $size[0];
 //               $imagesizey = $size[1];
            }
	}
$link = NV_BASE_SITEURL . "?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $global_array_cat[$catid]['alias'] . "/" . $alias . "-" . $id;
$bgcolor23 = $bgcolor1;
$bgcolor_23 = $bgcolor_1;

if ($a%2 == 1) { $bgcolor23 = $bgcolor2;$bgcolor_23 = $bgcolor_2; }
//$content .= "<tr>\n<td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"3\" width=\"100%\" bgcolor=\"$bgcolor23\"><tr>\n";
$content .= "<tr>\n<td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"3\" width=\"100%\"  bgcolor=\"$bgcolor_23\"><tr>\n";
if ($imgurl !="")
$content .= "<td width=\"30%\" align=\"left\"><img src=\"$imgurl\" width =\"50\" height =\"40\"></td><td width=\"70%\" align=\"left\"><a href=\"$link\"><font size=\"2\" color=\"$bgcolor23\">$hometext</a></font></td></tr></table></td>\n</tr>\n"; 
else
$content .= "<td width=\"1000%\" align=\"left\"><a href=\"$link\"><font size=\"2\" color=\"$bgcolor23\">$hometext</a></font></td></tr></table></td>\n</tr>\n"; 
$a=$a+1; 
} 

$content .= "</table>\n"; 
if ($Scroll) { 
$content .= "</marquee>"; 
} 
$content .= "</td>\n</tr>\n</table>\n"; 
} 
?>